﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace DAO
{
    public class CTHoaDonDAO
    {
        public static int ThemCT(CTHoaDonDTO ct)
        {

           string sql = string.Format("insert into CHITIETHOADON(MAHD,MACTDM,SOLUONG,DONGIA) values('{0}','{1}','{2}','{3}')", ct.Mahd, ct.Mactdm, ct.Soluong, ct.Dongia);
           return DataProvider.ExcuteNonQuery(sql);
        }
        public static DataTable GetChiTiet(int mahd)
        {
            string sql = string.Format("Select hd.DONGIA,hd.SOLUONG,m.TENMON,hd.DONGIA*hd.SOLUONG as THANHTIEN from CHITIETHOADON hd,CHITIETDATMON dm,MONAN m where hd.MAHD={0} and hd.MACTDM=dm.MACTDM and dm.MAMONAN=m.MAMONAN", mahd);
            return DataProvider.ExcuteQuery(sql);
        }

    }
}
